<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Flash Manager</title>
<link href="tabs.css" rel="stylesheet" type="text/css" />
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="alias.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="alias.js"></script>

<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>


<script type="text/javascript">
  jQuery(document).ready(function () {
    if(gref){ // Number all _img and _table classes
      gref();
    }
  });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->

<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">nRF51822 BLE SDK
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('group__ble__flash__module.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Flash Manager</div>  </div>
<div class="ingroups"><a class="el" href="group__ble__sdk__lib.html">Bluetooth Libraries</a></div></div>
<div class="contents">

<p>Module for accessing flash memory.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__flash__module.html#gae80848c09ea4534c232ecc19fe5c1221">ble_flash_init</a> (uint8_t elem_size)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes the flash manager.  <a href="#gae80848c09ea4534c232ecc19fe5c1221"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__flash__module.html#ga4aef9cc7c514d95befafb92d35d8a4a0">ble_flash_write</a> (uint8_t page_num, uint32_t *p_in_array, uint8_t elem_count)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Writes the flash at the given page with the given data.  <a href="#ga4aef9cc7c514d95befafb92d35d8a4a0"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__flash__module.html#ga6602056a8dbec6f010b5f717fed92bf8">ble_flash_read</a> (uint8_t page_num, uint32_t *p_out_array, uint8_t *p_elem_count)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Reads data from flash to RAM.  <a href="#ga6602056a8dbec6f010b5f717fed92bf8"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__flash__module.html#gac63ba6cc6f4b138d9a7d6ac9d734b30b">ble_flash_page_erase</a> (uint8_t page_num)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Erases a flash page.  <a href="#gac63ba6cc6f4b138d9a7d6ac9d734b30b"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<p>Module for accessing flash memory. </p>
<p>It contains functions for reading, writing and erasing one page in flash.</p>
<p>The module uses the first 32 bits of the flash page to write a magic number in order to determine if the page has been written or not.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>Be careful not to use a page number in the SoftDevice area (which currently occupies the range 0 to 127), or in your application space! In both cases, this would end up with a hard fault. </dd></dl>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="gae80848c09ea4534c232ecc19fe5c1221"></a><!-- doxytag: member="ble_flash.h::ble_flash_init" ref="gae80848c09ea4534c232ecc19fe5c1221" args="(uint8_t elem_size)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ble_flash_init </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>elem_size</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initializes the flash manager. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">elem_size</td><td>Size, in number of bytes, of a single element to handle in flash. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="ble__flash_8c_source.html#l00084">84</a> of file <a class="el" href="ble__flash_8c_source.html">ble_flash.c</a>.</p>

</div>
</div>
<a class="anchor" id="ga4aef9cc7c514d95befafb92d35d8a4a0"></a><!-- doxytag: member="ble_flash.h::ble_flash_write" ref="ga4aef9cc7c514d95befafb92d35d8a4a0" args="(uint8_t page_num, uint32_t *p_in_array, uint8_t elem_count)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t ble_flash_write </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>page_num</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t *&#160;</td>
          <td class="paramname"><em>p_in_array</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>elem_count</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Writes the flash at the given page with the given data. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>This operation blocks the CPU, so it should not be done while the radio is running!</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">page_num</td><td>Page number to update. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">p_in_array</td><td>Pointer to a RAM area containing the elements to write in flash. This area has to be 32 bits aligned. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">elem_count</td><td>Number of elements to write in flash. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>NRF_SUCCESS on successful flash write, otherwise an error code. </dd></dl>

<p>Definition at line <a class="el" href="ble__flash_8c_source.html#l00098">98</a> of file <a class="el" href="ble__flash_8c_source.html">ble_flash.c</a>.</p>

</div>
</div>
<a class="anchor" id="ga6602056a8dbec6f010b5f717fed92bf8"></a><!-- doxytag: member="ble_flash.h::ble_flash_read" ref="ga6602056a8dbec6f010b5f717fed92bf8" args="(uint8_t page_num, uint32_t *p_out_array, uint8_t *p_elem_count)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t ble_flash_read </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>page_num</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t *&#160;</td>
          <td class="paramname"><em>p_out_array</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>p_elem_count</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Reads data from flash to RAM. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">page_num</td><td>Page number to read. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">p_out_array</td><td>Pointer to a RAM area where the found data will be written. This area has to be 32 bits aligned. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">elem_count</td><td>Number of elements read. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>NRF_SUCCESS on successful upload, NRF_ERROR_NOT_FOUND if no valid data has been found in flash (first 32 bits not equal to the MAGIC_NUMBER. </dd></dl>

<p>Definition at line <a class="el" href="ble__flash_8c_source.html#l00134">134</a> of file <a class="el" href="ble__flash_8c_source.html">ble_flash.c</a>.</p>

</div>
</div>
<a class="anchor" id="gac63ba6cc6f4b138d9a7d6ac9d734b30b"></a><!-- doxytag: member="ble_flash.h::ble_flash_page_erase" ref="gac63ba6cc6f4b138d9a7d6ac9d734b30b" args="(uint8_t page_num)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ble_flash_page_erase </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>page_num</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Erases a flash page. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>This operation blocks the CPU, so it should not be done while the radio is running!</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">page_num</td><td>Page number to erase. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="ble__flash_8c_source.html#l00091">91</a> of file <a class="el" href="ble__flash_8c_source.html">ble_flash.c</a>.</p>

</div>
</div>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">
      Copyright &copy 2006-2011 <a href="http://www.nordicsemi.no" style="text-decoration:none">Nordic Semiconductor</a>.
      All Rights Reserved.
      <a href="disclaimer.html">Disclaimer</a>
    </li>
   </ul>
 </div>


</body>
</html>
